package com.imooc.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class UploadTestController {

    @RequestMapping(value = "uploadPre",method = RequestMethod.GET)
    public String uploadPre(){
        return "upload_page";
    }

    @RequestMapping(value = "upload")
    @ResponseBody
    public String upload(String name, MultipartFile photo){
        if(photo != null){
            System.out.println("[*** 文件上传 ***] name = "+ name);

            System.out.println("[*** 文件上传 ***] photoName = "+ photo.getName());
            String photoName = String.valueOf(photo.getName());
            System.out.println("[*** 文件上传 ***] photoContentType = "+ photo.getContentType());
            String photoContentType = String.valueOf(photo.getContentType());
            System.out.println("[*** 文件上传 ***] photoSize = "+ photo.getSize());
            Long Size = photo.getSize();
            return "upload_file"+"name = "+ name+"[***] photoName = "
                    + photoName+"[***] photoContentType = "+ photoContentType+"[***] Size = "+ Size;
        }
        return "upload_file:null";
    }

}
